import {
  q as t,
  p as E,
  ap as G,
  X as D,
  f as X,
  H as $,
  av as C,
  aw as K,
  k as o,
  m as c,
  l as h,
  ax as S,
  az as Q,
  as as r,
  aG as Z,
  at as _
} from "./index-30f27935.js";
import { i as B } from "./vip-8a4bc37f.js";
function ae(Y) {
  const m = t([]),
    a = t(!0);
  t({}), E();
  const W = t(1),
    f = t(""),
    g = t(""),
    v = t(10),
    n = t([]),
    b = t(""),
    I = G("reload"),
    y = D({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    M = D({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    z = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      {
        label: "档位",
        prop: "user_position",
        minWidth: 100,
        formatter: ({ user_position: e }) =>
          e == 1
            ? o(
                h("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [c("1799档位")] }
              )
            : e == 2
            ? o(
                h("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [c("5000档位")] }
              )
            : o(
                h("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [c("暂无")] }
              )
      },
      {
        label: "商品名称",
        prop: "wares",
        minWidth: 250,
        formatter: ({ wares: e, activity: l }) =>
          o("div", null, [
            o("div", null, [e]),
            l == 1
              ? o(
                  h("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [c("已赠送")] }
                )
              : ""
          ])
      },
      { label: "商品价格", prop: "wares_price", minWidth: 100 },
      { label: "商品数量", prop: "wares_num", minWidth: 100 },
      { label: "内含数量", prop: "all_bottle", minWidth: 100 },
      { label: "单位", prop: "wares_unit", minWidth: 100 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "创建时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => S(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      }
    ],
    J = X(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]),
    k = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 100 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      { label: "档位", prop: "user_position", minWidth: 100 },
      { label: "商品名称", prop: "wares", minWidth: 100 },
      { label: "商品价格", prop: "wares_price", minWidth: 100 },
      { label: "商品数量", prop: "wares_num", minWidth: 100 },
      { label: "内含数量", prop: "all_bottle", minWidth: 100 },
      { label: "单位", prop: "wares_unit", minWidth: 100 },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "创建时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => S(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "", minWidth: 180, prop: "0" }
    ];
  async function H(e) {
    Q(e);
  }
  async function N(e) {
    const l = { role_id: e.role_id },
      s = JSON.stringify(l),
      p = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(s)) },
      i = await Z(p);
    i.code == 200
      ? (_("删除成功", { type: "success" }), I())
      : _(i.msg, { type: "error" });
  }
  function U() {}
  function F(e) {
    (v.value = e), w(void 0, e);
  }
  function L(e) {
    (W.value = e), w(e, void 0);
  }
  function T(e) {}
  function V(e) {
    (M.text = `正在加载第${e}页...`),
      (a.value = !0),
      C(600).then(() => {
        a.value = !1;
      });
  }
  async function O(e, l = [], s, d) {
    (n.value = []),
      (a.value = !0),
      (b.value = e.user_phone),
      l.map(j => {
        const P = j,
          q = new Date(P);
        n.value.push(
          q.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      });
    const p = {
        page: 1,
        pagesize: v.value,
        user_phone: e.user_phone ? e.user_phone : void 0,
        start: n.value[0],
        end: n.value[1],
        action: s || void 0,
        indent: d || void 0
      },
      i = JSON.stringify(p),
      A = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(i)) },
      { data: x } = await B(A);
    (m.value = x.data),
      (y.total = x.total),
      setTimeout(() => {
        a.value = !1;
      }, 500);
  }
  async function w(e = W.value, l = v.value) {
    const s = {
        page: e,
        pagesize: l,
        user_phone: b.value ? b.value : void 0,
        start: n.value[0],
        end: n.value[1],
        action: f.value ? f.value : void 0,
        indent: g.value ? g.value : void 0
      },
      d = JSON.stringify(s),
      i = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(d)) },
      u = await B(i);
    u.code === 200
      ? ((m.value = u.data.data),
        (y.total = u.data.total),
        setTimeout(() => {
          a.value = !1;
        }, 500))
      : _(u.msg, { type: "error" });
  }
  const R = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    $(() => {
      C().then(() => {
        const { setWatermark: e } = K(Y.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        (a.value = !1);
    }),
    {
      loading: a,
      columns: z,
      dataList: m,
      pagination: y,
      buttonClass: J,
      formattedDate: n,
      columnsTable: k,
      onSearch: O,
      gradeVip: f,
      gradeVip1: g,
      resetForm: R,
      handleaddUser: U,
      handleUpdate: H,
      handleDelete: N,
      handleSizeChange: F,
      handleCurrentChange: L,
      handleSelectionChange: T,
      onCurrentChange: V
    }
  );
}
export { ae as useRole };
